/*
 * mouse.h
 *
 *  Created on: 2021年3月13日
 *      Author: root
 */

#ifndef __MYOS__DRIVERS__MOUSE_H_
#define __MYOS__DRIVERS__MOUSE_H_

#include <hardwarecommunication/interrupts.h>
#include <hardwarecommunication/port.h>
#include <common/types.h>
#include <drivers/driver.h>

namespace myos{

	namespace drivers{

		class MouseEventHandle{

		public:
			MouseEventHandle();
			~MouseEventHandle();

			virtual void OnActivate();
			virtual void OnMouseDown(myos::common::uint8_t button );
			virtual void OnMouseUP(myos::common::uint8_t button );
			virtual void OnMouseMove(int x,int y);
		};

		class MouseDrive:public myos::hardwarecommunication::InterruptHandler,public Driver
		{

			myos::hardwarecommunication::Port8Bit dataport;			//数据窗口
			myos::hardwarecommunication::Port8Bit commandport; 		//命令窗口
			myos::common::uint8_t buffer[3];
			myos::common::uint8_t offset;
			myos::common::uint8_t buttons;
			MouseEventHandle * handler;

		public:
			MouseDrive(myos::hardwarecommunication::InterruptManager* manager ,MouseEventHandle * handler);
			~MouseDrive();
			virtual myos::common::uint32_t HandleInterrupt(myos::common::uint32_t esp);
			virtual void Activate();
		};
	}
}

#endif /* __MYOS__DRIVERS__MOUSE_H_ */
